package com.nakamachizu.controller;

import java.io.IOException;

import javax.xml.transform.TransformerException;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.util.StringUtil;
import org.w3c.dom.Document;

import com.nakamachizu.service.XmlGenService;

public class XmlController extends Controller {

    @Override
    public Navigation run() {
        
        XmlGenService service = new XmlGenService();
        try{
            Document xml = null;
            String ses = requestScope("ses");
            if(StringUtil.isEmpty(ses)){
                xml = service.makeXmlDocument();
            }else{
                xml = service.makeXmlDocument(request.getSession());
            }
            service.printXml(response.getOutputStream(), xml);
        }catch(IOException e){
            e.printStackTrace();
        }catch(TransformerException e){
            e.printStackTrace();
        }

        return null;
    }
    

}
